package internal

import (
	"github.com/gin-gonic/gin"
	"go-doc/internal/contoller"
	"go-doc/internal/middleware"
)

func InitRouter() *gin.Engine {
	r := gin.Default()

	// 要在路由组之前全局使用「跨域中间件」, 否则OPTIONS会返回404
	r.Use(middleware.Cors())

	api := r.Group("/api")
	{
		//api.GET("/ping", contoller.Ping)
		//api.GET("/logout", contoller.Ping)
	}

	authApi := api.Group("/auth")
	{
		authApi.POST("/login", contoller.AuthCtl.Login)
		authApi.GET("/logout", contoller.AuthCtl.Logout)
	}

	//userApi := api.Group("/user")
	//{
	//
	//}
	//
	//roleApi := api.Group("/role")
	//{
	//
	//}
	return r
}
